//
//  HWMineFuncCell.swift
//  HWPromoteProjectAPP
//
//  Created by 王昌健 on 2022/1/29.
//  Copyright © 2022 王昌健. All rights reserved.
//

import UIKit

class HWMineFuncCell: UICollectionViewCell {
    var imageView:UIImageView!
    var titleLabel:UILabel!
    var model:HWMineDataModel? {
        didSet {
            imageView.sd_setImage(with: URL(string: model?.icon ?? ""), completed: nil)
            titleLabel.text = model?.name
        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        initUI()
        
        initFrame()
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

extension HWMineFuncCell {
    private func initUI() -> Void {
        
        imageView = UIImageView()
        imageView.backgroundColor = .clear
        contentView.addSubview(imageView)
        
        titleLabel = HWLabel.createLabel(title: "", color: "#444444", font: 12*widthScale)
        titleLabel.textAlignment = .center
        contentView.addSubview(titleLabel)
    }
    
    private func initFrame() -> Void {
        imageView.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.width.height.equalTo(24*widthScale)
            make.top.equalTo(0)
        }
        
        titleLabel.snp.makeConstraints { make in
            make.left.right.equalToSuperview()
            make.top.equalTo(imageView.snp.bottom).offset(6*widthScale)
        }
    }
}
